<?php
$T->loadTpl("./html/".$template."/".$qname.".html");
$T->SetTpl('cssjs','html/cssjs.inc'); 
$T->SetTpl('jsmodel','html/jsmodel.inc');     
 
$p=isset($_GET["p"])?$_GET["p"]:"1";
$offset = ($p-1)*15;
if($offset<0) $offset = 0;
$quiz1=isset($_GET['quiz1'])?$_GET['quiz1']:"";
$quiz2=isset($_GET['quiz2'])?$_GET['quiz2']:"";
$xs1='';
$xs2='';
$readY='';
$readN='';
//echo $quiz1;
//$uid='ytt';
$uid=$_SESSION['uid'];
//echo $uid;
if($quiz1==1){
	$xs1='selected';
	$xs2='';
}
if($quiz1==2){
	$xs2='selected';
	$xs1='';
}
if($quiz2==1){
	$readY='selected';
	$readN='';
}
if($quiz2==2){
	$readN='selected';
	$readY='';
}
$n_where="where 1=1 and (A.sender='".$_SESSION['uid']."' or A.accepter='".$_SESSION['uid']."')  ";
$C_where="where 1=1 and (sender='".$_SESSION['uid']."' or accepter='".$_SESSION['uid']."')";
if($quiz1==1){
	$n_where .= " and A.accepter='".$uid."' ";
	$C_where .= " and accepter='".$uid."' ";
}else if($quiz1==2){
	$n_where .= " and A.sender='".$uid."' ";
	$C_where .= " and sender='".$uid."' ";
}
if($quiz2==1){
	$n_where .= " and A.is_read=1 ";
	$C_where .= " and is_read=1 ";
}else if($quiz2==2){
	$n_where .= " and A.is_read=0 ";
	$C_where .= " and is_read=0 ";
}
$T->SetBlock("list","select A.*,B.truename as s_name,C.truename as a_name from sys_news as A left join sys_member as B on B.id=A.sender left join sys_member as C on C.id=A.accepter ".$n_where." order by A.id desc limit {$offset},15 ");
if($p<1)$p=1;
$rc=$T->db->query("select count(*) from sys_news ".$C_where)->fetchColumn(0);
$page=getPageHtml_bt($rc,15,$p,"&t=news_sys&quiz1=".$quiz1."&quiz2=".$quiz2);
$page=mb_convert_encoding($page, 'utf-8', 'utf-8');
$T->Set("page",$page);
$T->Set("xs1",$xs1);
$T->Set("xs2",$xs2);
$T->Set("readY",$readY);
$T->Set("readN",$readN);
		 

$T->Set("template",$template);         
$T->clearNaN();       
$T->clearNoN();
$T->display(); 